use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

///
/// Struct to hold the results of Struct yata::indicators::DetrendedPriceOscillator Detrended Price Oscillator
///
///  参见[DPO](https://en.wikipedia.org/wiki/Detrended_price_oscillator)
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct DPO {
    // §Has no signals
    /// 1 value
    /// DPO value
    /// Range in (-inf; +inf).
    pub dpo: ValueType,
}

/// Configuration Detrended Price Oscillator
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct DPOConfig {
    /// ma: M
    /// Main moving average type.
    ///
    /// Default is SMA(21)
    ///
    /// Period range in [2; PeriodType::MAX)
    pub ma: PeriodType,
    // source: Source
    // Source type. Default is Close.
}

impl Default for DPOConfig {
    fn default() -> Self {
        Self { ma: 21 }
    }
}
